/*
   Copyright (c) [2023] [魔凤啸天]
   [MFUI] is licensed under Mulan PSL v2.
   You can use this software according to the terms and conditions of the Mulan PSL v2. 
   You may obtain a copy of Mulan PSL v2 at:
            http://license.coscl.org.cn/MulanPSL2 
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
   See the Mulan PSL v2 for more details.  
*/
#pragma once
#include "button.hpp"

namespace MFUI{
	class CheckButton:public Button{
		protected:
		//调用check和released
		void _released(Window* w,SDL_FPoint p)override;
		void _losefocus(Window* w)override;
		void _pressed(Window* w,SDL_FPoint p)override;
		~CheckButton()override;

		virtual void _changed();

		SDL_Color background;
		bool value;

		public:
		CheckButton(SDL_Color back,bool v);

		bool getvalue()const;
		void setvalue(bool v);
		//设置为相反的值并触发changed
		void check();
		void setbackground(SDL_Color c);
		SDL_Color getbackground()const;
		//实现自定义逻辑用
		virtual void changed();

		void draw(Renderer* r,bool updatecache)override;
		void mouseentered(Window* w)override;
		void mouseexited(Window* w)override;
	};
}